package io.seata.samples.tcc.springboot.dubbo.controller;

import io.seata.samples.tcc.springboot.dubbo.model.User;
import io.seata.samples.tcc.springboot.dubbo.service.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RequestMapping("/user")
@RestController
public class UserController {

    @Resource
    private UserService userService;

    @PostMapping("/save")
    public User save(@RequestBody User user) {
        return userService.save(user);
    }

    @GetMapping("/delete")
    public boolean delete(Long id) {
        return userService.delete(id);
    }

    @GetMapping("/findById")
    public User findById(Long id) {
        return userService.findById(id);
    }

    @GetMapping("/list")
    public List<User> list() {
        return userService.list();
    }
}
